package sample.client.view.gxt;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.resources.CommonStyles;
import com.sencha.gxt.widget.core.client.ListViewCustomAppearance;

public class DocumentLooks extends ListViewCustomAppearance<Document>
{
  interface Style extends CssResource
  {
    String over();

    String select();

    String thumb();

    String thumbWrap();
  }

  interface CssResources extends ClientBundle
  {
    @Source("doc.css")
    Style css();
  }

  public final static CssResources resources = GWT.create(CssResources.class);

  public final static Style style = resources.css();

  private DocumentLooks() {
    super("." + style.thumbWrap(), style.over(), style.select());
  }

  public static DocumentLooks create() {
    return new DocumentLooks();
  }

  @Override
  public void renderEnd(SafeHtmlBuilder builder) {
    String markup =
        new StringBuilder("<div class=\"").append(CommonStyles.get().clear())
            .append("\"></div>").toString();
    builder.appendHtmlConstant(markup);
  }

  @Override
  public void renderItem(SafeHtmlBuilder builder, SafeHtml content) {
    builder.appendHtmlConstant("<div class='" + style.thumbWrap()
        + "' style='border: 1px solid white'>");
    builder.append(content);
    builder.appendHtmlConstant("</div>");
  }

}
